//
//  SAStatisticsCommissionCell.m
//  saasRetail
//
//  Created by 黄志刚 on 2021/7/23.
//

#import "SAStatisticsCommissionCell.h"
#import "SAStatisticsCommissionModel.h"
#import "UILabel+NSMutableAttributedString.h"

@interface SAStatisticsCommissionCell ()

@property (nonatomic, strong) UILabel *empLab;
@property (nonatomic, strong) UILabel *totalLab;
@property (nonatomic, strong) UILabel *baseSalaryLab;
@property (nonatomic, strong) UILabel *saleLab;
@property (nonatomic, strong) UILabel *topUpLab;
@property (nonatomic, strong) UILabel *wholeShopLab;

@property (nonatomic, strong) UIView *line;

@end

@implementation SAStatisticsCommissionCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initUI];
    }
    return self;
}

-(void)setModel:(SAStatisticsCommissionModel *)model {
    _model = model;
    self.empLab.text = model.empName;
    self.totalLab.text = [NSString stringWithFormat:@"合计:￥%0.2lf",[model.totalAmount doubleValue]/100];
    [self.totalLab setAttributedStringWithSubString:@"合计:" color:kBlackColor];
    self.baseSalaryLab.text = [NSString stringWithFormat:@"底薪:￥%0.2lf",[model.basicWage doubleValue]/100];
    self.saleLab.text = [NSString stringWithFormat:@"销售:￥%0.2lf",[model.saleRateAmount doubleValue]/100];
    self.topUpLab.text = [NSString stringWithFormat:@"充值:￥%0.2lf",[model.rechargeRateAmount doubleValue]/100];
    self.wholeShopLab.text = [NSString stringWithFormat:@"整店:￥%0.2lf",[model.wholeRateAmount doubleValue]/100];
    
}

-(void)initUI {
    [self.contentView addSubview:self.empLab];
    [self.contentView addSubview:self.totalLab];
    [self.contentView addSubview:self.baseSalaryLab];
    [self.contentView addSubview:self.saleLab];
    [self.contentView addSubview:self.topUpLab];
    [self.contentView addSubview:self.wholeShopLab];
    [self.contentView addSubview:self.line];
}

-(UILabel *)empLab {
    if (!_empLab) {
        _empLab = [[UILabel alloc] initWithFrame:SARectMake(28, 5, 150, 20)];
        _empLab.textColor = kBlackColor;
        _empLab.textAlignment = NSTextAlignmentLeft;
        _empLab.font = kFont(16);
    }
    return _empLab;
}

-(UILabel *)totalLab {
    if (!_totalLab) {
        _totalLab = [[UILabel alloc] initWithFrame:SARectMake(190, 5, 160, 20)];
        _totalLab.textColor = kPinkColor;
        _totalLab.font = kFont(16);
        _totalLab.textAlignment = NSTextAlignmentLeft;
    }
    return _totalLab;
}

-(UILabel *)baseSalaryLab {
    if (!_baseSalaryLab) {
        _baseSalaryLab = [[UILabel alloc] initWithFrame:SARectMake(28, 33, 150, 20)];
        _baseSalaryLab.textColor = kLightgGrayColor;
        _baseSalaryLab.font = kFont(14);
        _baseSalaryLab.textAlignment = NSTextAlignmentLeft;
    }
    return _baseSalaryLab;
}

-(UILabel *)saleLab {
    if (!_saleLab) {
        _saleLab = [[UILabel alloc] initWithFrame:SARectMake(190, 33, 160, 20)];
        _saleLab.textColor = kLightgGrayColor;
        _saleLab.font = kFont(14);
        _saleLab.textAlignment = NSTextAlignmentLeft;
    }
    return _saleLab;
}

-(UILabel *)topUpLab {
    if (!_topUpLab) {
        _topUpLab = [[UILabel alloc] initWithFrame:SARectMake(28, 55, 150, 20)];
        _topUpLab.textColor = kLightgGrayColor;
        _topUpLab.font = kFont(14);
        _topUpLab.textAlignment = NSTextAlignmentLeft;
    }
    return _topUpLab;
}

-(UILabel *)wholeShopLab {
    if (!_wholeShopLab) {
        _wholeShopLab = [[UILabel alloc] initWithFrame:SARectMake(190, 55, 160, 20)];
        _wholeShopLab.textColor = kLightgGrayColor;
        _wholeShopLab.font = kFont(14);
        _wholeShopLab.textAlignment = NSTextAlignmentLeft;
    }
    return _wholeShopLab;
}

-(UIView *)line {
    if (!_line) {
        _line = [[UIView alloc] initWithFrame:CGRectMake(0, kScaleNum(80), kScreenWidth, kScaleNum(0.5))];
        _line.backgroundColor = kLineColor;
    }
    return _line;
}

@end
